package com.chinaisafe.user.vo.response;

import com.chinaisafe.user.entity.SysAccount;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import lombok.experimental.Accessors;

import java.io.Serial;
import java.io.Serializable;

/**
 * SysAccountRespVO
 * Description：账号响应值对象
 *
 * @author xuefu.shu
 * @date  2024-07-13 13:31:45
 */
@Getter
@Setter
@ToString
@Accessors(chain = true)
@Schema(name = "SysAccountRespVO", description = "账号响应值对象")
public class SysAccountRespVO implements Serializable {

    @Serial
    private static final long serialVersionUID = 1L;

    @Schema(description = "主键id")
    private Long id;

    @Schema(description = "乐观锁版本")
    private Integer version;

    @Schema(description = "手机号")
    private String mobile;

    @Schema(description = "密码")
    private String password;

    @Schema(description = "微信openid")
    private String wxOpenid;

    @Schema(description = "用户类别")
    private Integer userType;

    @Schema(description = "主租户")
    private String mainTenantCode;

    @Schema(description = "是否第一次登录")
    private Boolean firstLogin;

    @Schema(description = "网关路由标记")
    private String nodeLabel;


    /**
     * 将实体类转换为响应值对象
     * @param entity 实体对象
     * @return SysAccountRespVO 响应值对象
     * @author xuefu.shu
     * @date 2024-07-13 13:31:45
     */
    public static SysAccountRespVO convertFromEntity(SysAccount entity) {
        SysAccountRespVO respVO = new SysAccountRespVO();
        respVO.id = entity.getId();
        respVO.version = entity.getVersion();
        // 给对应的字段赋值 可根据实际业务删减
        respVO.mobile = entity.getMobile();
        respVO.password = entity.getPassword();
        respVO.wxOpenid = entity.getWxOpenid();
        respVO.userType = entity.getUserType();
        respVO.mainTenantCode = entity.getMainTenantCode();
        respVO.firstLogin = entity.getFirstLogin();
        respVO.nodeLabel = entity.getNodeLabel();
        return respVO;
    }
}
